class crond::pbsclean {
  cron { 'checkjoboutput':
    command => "/root/bin/checkjoboutput.py",
    user    => 'root',
    hour    => '*/2',
    minute  => 0
  }

  cron { 'clean-scratch':
    command => "ls -al /scratch/ |grep -v  ' root '|grep -v condor|awk '{print \$9}'|xargs -I {} find /scratch/{} -maxdepth 1 -mtime +14  |xargs rm -rf",
    user    => 'root',
    hour    => 4,
    minute  => 33
  }

  cron { 'clean-undeliver':
    command => 'find /var/spool/pbs/undelivered/ -mtime +3 -maxdepth 1  -exec rm -f {} \;',
    user    => 'root',
    hour    => 4,
    minute  => 44
  }

  #cron { 'clean-eoslog':
  #  command => 'find /var/log/eos/fuse -mtime +2 -exec rm -f {} \;',
  #  user    => 'root',
  #  hour    => 1,
  #  minute  => 11, 
  #}

  cron { 'momlogzip':
    command => 'find /var/spool/pbs/mom_logs -mtime +2 -exec gzip -9 {} \;',
    user    => 'root',
    hour    => 3,
    minute  => 33
  }
  file { "/root/bin/checkjoboutput.py":
     ensure   => file,
     owner    => 0,
     group    => 0,
     content  => template("crond/checkjoboutput.py.erb"),
     mode     => '0755',
     require  => File['/root/bin'],
  }
}
